<%@  page  import ="web_hr.Model,web_hr.CheckLogin,java.sql.*"   language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!---->  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../Res/Bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="./Res/Css/login.css">
<style>
label{
	width:130px;
	font-size:17px;
}

.line{
	margin-top:15px;
	
}

#submit{
	width:120px;
}
#reset{
	position:absolute;
	left:24%;
	width:120px;
}
</style>

<title>Login</title>
<script src="../Res/JQuery/jquery-1.8.3.min.js"></script>
<script>
<%--  
	丢失焦点判断oldpassword是否为空
	为空提示，不为空时传入check_oldpassword.jsp判断原密码是否正确
--%>
$(document).ready(function(){
	var flag =0;
	$("[name='password']").focusout(function(){
		if($(this).val().length==0 ){
			if(flag ==0){
				$("#w1").remove();
				$(this).after("<span id='warming'><font color = red >&nbsp;&nbsp;&nbsp;&nbsp;Oldpassword  must be filled!</font></span>");
				flag =1;
			}
		}else{
			$("#warming").remove();	
			flag =0;
			$.ajax({
				type:"post",
				url:"./check_oldpassword.jsp",
				data:{password:$("input[name='password']").val()},
				success:function(data,textStatus){
					$("#w1").remove();
					$("[name='password']").after(data);
					//alert(data);
				}
			});
		}
	});
});	
</script>
<script>
<%--  
	丢失焦点判断新密码是否为空
	为空提示，不为空传入check_newpassword1.jsp判断格式是否正确
--%>
$(document).ready(function(){
	var flag =0;
	$("[name='password1']").focusout(function(){
		if($(this).val().length==0 ){
			if(flag ==0){
				$("#w2").remove();
				$(this).after("<span id='warming2'><font color = red >&nbsp;&nbsp;&nbsp;&nbsp;New password  must be filled!</font></span>");
				flag =1;
			}
		}else{
			$("#warming2").remove();	
			flag =0;
			$.ajax({
				type:"post",
				url:"./check_newpassword1.jsp",
				data:{password1:$("input[name='password1']").val()},
				success:function(data,textStatus){
					$("#w2").remove();
					$("[name='password1']").after(data);
					//alert(data);
				}
			});
		}
	});
});	

</script>
<script>
<%--  
	丢失焦点判断新密码是否为空
	为空提示，不为空传入check_newpassword2.jsp判断格式是否正确
--%>
$(document).ready(function(){
	var flag =0;
	$("[name='password2']").focusout(function(){
		if($(this).val().length==0 ){
			if(flag ==0){
				$("#w3").remove();
				$(this).after("<span id='warming3'><font color = red >&nbsp;&nbsp;&nbsp;&nbsp;New password  must be filled!</font></span>");
				flag =1;
			}
		}else{
			$("#warming3").remove();	
			flag =0;
			$.ajax({
				type:"post",
				url:"./check_newpassword2.jsp",

				data:{password2:$("input[name='password2']").val()},


				success:function(data,textStatus){
					$("#w3").remove();
					$("[name='password2']").after(data);
					//alert(data);
				}
			});
		}
	});
});	

<%-- 点击reset时清空提示 --%>
$(document).ready(function(){
	$("#reset").click(function(){
		$("#warming").remove();
		$("#w1").remove();
		$("#warming2").remove();
		$("#w2").remove();
		$("#warming3").remove();
		$("#w3").remove();
	});
});
</script>
</head>
<body class="container">
<%-- submit提交时将数据传入Checkupdate.java验证并提交数据 --%>
<h2>Change Password</h2>
	<form action="../CheckUpdate" method="post" class="form-inline">		

	<div class="form-group line">
		<label for="password">OldPassword:</label><input class="form-control" id="password" name="password" type="password">
	</div><br/>
	<div class="form-group line">
		<label for="password">NewPassword:</label><input class="form-control" id="password1" name="password1" type="password">
	</div><br/>
	<div class="form-group line">
		<label for="password">NewPassword:</label><input class="form-control" id="password2" name="password2" type="password">
	</div><br/>	
	<div>&nbsp;</div>
	<div>&nbsp;</div>
		<input id="submit" class="btn btn-lg btn-primary" type="submit" value="submit">
		<input id="reset" class="btn btn-lg btn-default" type="reset" value="reset">
	</form>	
</body>
</html>
